/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aplikasirawatinap;
import Controller.onlyLetter;
import javax.swing.JScrollPane;
import Service.Koneksi;
import java.awt.event.ActionListener;
import java.sql.*;
import javax.swing.*;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

/**
 *
 * @author Saptaji
 */
public class PendaftaranForm extends javax.swing.JFrame {

    Connection con;
    PreparedStatement psmt,psmt2;
    String depe;
    int idp;
    private int ok;
    public PendaftaranForm() {
        setTitle("FORM PENDAFTARAN");
        initComponents();
        umur();
        tx_fname.setDocument(new onlyLetter().getOnlyLetter());
        tx_lname.setDocument(new onlyLetter().getOnlyLetter());
        tx_ayah.setDocument(new onlyLetter().getOnlyLetter());
        tx_diagnosa.setDocument(new onlyLetter().getOnlyLetter());
        tx_dokter.setDocument(new onlyLetter().getOnlyLetter());
        tx_peker.setDocument(new onlyLetter().getOnlyLetter());
        
    }
    
    private void savePasien() {
        try{
            /*String depe = tx_dp.getText();
            double harga = Double.parseDouble(depe);
            DecimalFormat df = (DecimalFormat) DecimalFormat.getCurrencyInstance();
            DecimalFormatSymbols dfs = new DecimalFormatSymbols();
            dfs.setCurrencySymbol("");
            dfs.setMonetaryDecimalSeparator(',');
            dfs.setGroupingSeparator('.');
            df.setDecimalFormatSymbols(dfs);
            String hsl = "Rp. " + df.format(harga);*/
            depe = tx_dp.getText();
            idp = Integer.parseInt(depe);
            tx_dp.setText("Rp. "+Integer.toString(idp));
            //String hsl = "Rp. "+depe;
           // tx_dp.setText(hsl);
             //tx_fname = new JFormattedTextField(NumberFormat.getInstance());
           if(idp>500000){JOptionPane.showMessageDialog(null,"DP tidak boleh lebih dari Rp. 5.00.000.00", "ERROR", JOptionPane.PLAIN_MESSAGE);
           tx_dp.setText("");}
           else if(tx_id.getText().equals("")){JOptionPane.showMessageDialog(null,"ID Pasien harus diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_fname.getText().equals("")){JOptionPane.showMessageDialog(null,"Nama Depan harus diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_lname.getText().equals("")){JOptionPane.showMessageDialog(null,"Nama Belakang harus diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_ayah.getText().equals("")){JOptionPane.showMessageDialog(null,"Nama ayah Harus Diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(txarea_alamat.getText().equals("")){JOptionPane.showMessageDialog(null,"Alamat Harus Diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_peker.getText().equals("")){JOptionPane.showMessageDialog(null,"Pekerjaan Harus Diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_umur.getText().equals("")){JOptionPane.showMessageDialog(null,"Umur Harus Diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_dokter.getText().equals("")){JOptionPane.showMessageDialog(null,"Dokter Harus Diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else if(tx_diagnosa.getText().equals("")){JOptionPane.showMessageDialog(null,"Diagnosa Harus Diisi", "ERROR", JOptionPane.PLAIN_MESSAGE);}   
           else if(tx_dp.getText().length()>10){JOptionPane.showMessageDialog(null,"dp terlalu besar", "ERROR", JOptionPane.PLAIN_MESSAGE);}
           else{
                
                String idpas =tx_id.getText();
                con = Koneksi.getConnection();
                Statement st=con.createStatement();
                String sql1="Select id_pasien FROM pasien Where id_pasien='" + idpas + "'";
                ResultSet rs=st.executeQuery(sql1);
                if(rs.next()){JOptionPane.showMessageDialog(null,"ID Pasien "+idpas+" Sudah ada Di DataBase", "ERROR", JOptionPane.PLAIN_MESSAGE);}
                else{
                ok = JOptionPane.showConfirmDialog(null, "Anda yakin akan menyimpan data pasien ini?", "Konfirmasi", JOptionPane.OK_CANCEL_OPTION);
                if (ok == 0){
                    String sql2 = "Insert into pasien "+"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                    psmt = con.prepareStatement(sql2);
                    psmt.setString(1,tx_id.getText());
                    psmt.setString(2,(String)combo_daym.getSelectedItem()+" "+combo_monthm.getSelectedItem()+" "+combo_yearm.getSelectedItem());
                    psmt.setString(3,tx_fname.getText());
                    psmt.setString(4,tx_lname.getText());
                    psmt.setString(5,(String) combo_gender.getSelectedItem());
                    psmt.setString(6,(String)combo_dayl.getSelectedItem()+" "+combo_monthl.getSelectedItem()+" "+combo_yearl.getSelectedItem());
                    psmt.setString(7,tx_ayah.getText());
                    psmt.setString(8,(String)combo_agama.getSelectedItem());
                    psmt.setString(9,txarea_alamat.getText());
                    psmt.setString(10,tx_peker.getText());
                    psmt.setString(11,tx_umur.getText());
                    psmt.setString(12,(String)combo_darah.getSelectedItem());
                    psmt.setString(13,(String)combo_status.getSelectedItem());
                    psmt.setString(14,(String)combo_nmruangan.getSelectedItem());
                    psmt.setString(15,(String)combo_kruangan.getSelectedItem());
                    psmt.setString(16,(String)combo_loca.getSelectedItem());
                    psmt.setString(17,tx_dokter.getText());
                    psmt.setString(18,tx_diagnosa.getText());
                    psmt.setString(19,tx_dp.getText());
                    psmt.executeUpdate();
                    JOptionPane.showMessageDialog(null, "data pasien telah ditambah");
                    psmt.close();
                    }
                    tx_dp.setText(Integer.toString(idp));
                }
           }
            
        }
        catch(Exception e)
        {
           JOptionPane.showMessageDialog(null, e);
        }
    }
    public void lokasiRuangan() {
        
        Object select1 = combo_nmruangan.getSelectedItem();
        Object select2 = combo_kruangan.getSelectedItem();
        if(select1=="Mawar"&&select2=="Kelas-1")
        { 
            
            combo_loca.removeAllItems();
            combo_loca.addItem("Mawar, kelas-1, 101");
            combo_loca.addItem("Mawar, kelas-1, 102");
        }
        else if(select1=="Mawar"&&select2=="Kelas-2")
        {
            combo_loca.removeAllItems();
            combo_loca.addItem("Mawar, kelas-2, 201");
            combo_loca.addItem("Mawar, kelas-2, 202");      
        }
        else if(select1=="Mawar"&&select2=="VIP")
        {
            combo_loca.removeAllItems();
            combo_loca.addItem("Mawar, VIP, 301");
            combo_loca.addItem("Mawar, VIP, 302");      
        }
        else if(select1=="Melati"&&select2=="Kelas-1")
        {
            combo_loca.removeAllItems();
            combo_loca.addItem("Melati, kelas-1, 101");
            combo_loca.addItem("Melati, kelas-1, 102");
            
        }
        else if(select1=="Melati"&&select2=="Kelas-2")
        {
            combo_loca.removeAllItems();
            combo_loca.addItem("Melati, kelas-2, 201");
            combo_loca.addItem("Melati, kelas-2, 202");
        }
        else if(select1=="Melati"&&select2=="VIP")
        {
            combo_loca.removeAllItems();
            combo_loca.addItem("Melati, VIP, 301");
            combo_loca.addItem("Melati, VIP, 302");
        }
        else if(select1=="--pilih--"&&select2=="--pilih--")
        {
            combo_loca.removeAllItems();
            JOptionPane.showMessageDialog(null,"Belum di pilih", "ERROR", JOptionPane.PLAIN_MESSAGE);
        }
    }
    
    private void searchPasien()
    {
        try
        {
            con = Koneksi.getConnection();
            
            String search ="Select * from pasien where id_pasien like '%" + tx_searchid.getText() + "%'";
            PreparedStatement statement = con.prepareStatement(search);
            ResultSet rs =statement.executeQuery(search);
            String id =tx_id.getText();
            while (rs.next()) {
                 tx_id.setText(rs.getString("id_pasien"));
            }
        }
        catch (SQLException e) {
              JOptionPane.showMessageDialog(this, "Koneksi gagal: " +e);
        } 
    }
    
    public void umur() {
        String tahun = String.valueOf(combo_yearm.getSelectedItem());
        String tahun2 = String.valueOf(combo_yearl.getSelectedItem());
        int itahun = Integer.parseInt(tahun);
        int itahun2 = Integer.parseInt(tahun2);
        int umur = itahun-itahun2;
        tx_umur.setText(Integer.toString(umur));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tx_searchid = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        l_tm = new javax.swing.JLabel();
        l_fname = new javax.swing.JLabel();
        l_lname = new javax.swing.JLabel();
        l_gender = new javax.swing.JLabel();
        l_tl = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tx_fname = new javax.swing.JTextField();
        combo_daym = new javax.swing.JComboBox();
        combo_monthm = new javax.swing.JComboBox();
        combo_yearm = new javax.swing.JComboBox();
        combo_dayl = new javax.swing.JComboBox();
        combo_monthl = new javax.swing.JComboBox();
        combo_yearl = new javax.swing.JComboBox();
        tx_lname = new javax.swing.JTextField();
        combo_gender = new javax.swing.JComboBox();
        tx_ayah = new javax.swing.JTextField();
        l_alamat = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txarea_alamat = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        tx_dp = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        b_save = new javax.swing.JButton();
        b_clear = new javax.swing.JButton();
        l_nmruangan = new javax.swing.JLabel();
        l_kruangan = new javax.swing.JLabel();
        combo_nmruangan = new javax.swing.JComboBox();
        combo_kruangan = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        combo_loca = new javax.swing.JComboBox();
        l_darah = new javax.swing.JLabel();
        combo_darah = new javax.swing.JComboBox();
        l_diagnosa = new javax.swing.JLabel();
        tx_diagnosa = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        tx_dokter = new javax.swing.JTextField();
        L_UMUR = new javax.swing.JLabel();
        tx_umur = new javax.swing.JTextField();
        l_agama = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        combo_status = new javax.swing.JComboBox();
        combo_agama = new javax.swing.JComboBox();
        l_peker = new javax.swing.JLabel();
        tx_peker = new javax.swing.JTextField();
        l_id = new javax.swing.JLabel();
        tx_id = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        l_tm.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_tm.setText("Tanggal Masuk");

        l_fname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_fname.setText("Nama Depan");

        l_lname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_lname.setText("Nama Belakang");

        l_gender.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_gender.setText("Gender");

        l_tl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_tl.setText("Tanggal Lahir");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Nama Ayah Kandung");

        tx_fname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        combo_daym.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_daym.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        combo_monthm.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_monthm.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" }));

        combo_yearm.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_yearm.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030" }));
        combo_yearm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_yearmActionPerformed(evt);
            }
        });

        combo_dayl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_dayl.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        combo_monthl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_monthl.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" }));

        combo_yearl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_yearl.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015" }));
        combo_yearl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_yearlActionPerformed(evt);
            }
        });

        tx_lname.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        combo_gender.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_gender.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Male", "Female" }));

        tx_ayah.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        l_alamat.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_alamat.setText("Alamat");

        txarea_alamat.setColumns(20);
        txarea_alamat.setRows(5);
        jScrollPane1.setViewportView(txarea_alamat);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("DP");

        tx_dp.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel2.setText("FORM PENDAFTARAN PASIEN");

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/registration.png"))); // NOI18N

        b_save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/save.png"))); // NOI18N
        b_save.setText("SIMPAN DATA PASIEN");
        b_save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_saveActionPerformed(evt);
            }
        });

        b_clear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/clear.png"))); // NOI18N
        b_clear.setText("BERSIHKAN");
        b_clear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_clearActionPerformed(evt);
            }
        });

        l_nmruangan.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_nmruangan.setText("Nama Ruangan");

        l_kruangan.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_kruangan.setText("Kelas Ruangan");

        combo_nmruangan.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_nmruangan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--pilih--", "Melati", "Mawar" }));
        combo_nmruangan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_nmruanganActionPerformed(evt);
            }
        });

        combo_kruangan.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_kruangan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--pilih--", "Kelas-1", "Kelas-2", "VIP" }));
        combo_kruangan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_kruanganActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("LOKASI");

        combo_loca.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        l_darah.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_darah.setText("Gol. Darah");

        combo_darah.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_darah.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A", "B", "O", "AB" }));

        l_diagnosa.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_diagnosa.setText("Diagnosa");

        tx_diagnosa.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("Nama Dokter");

        L_UMUR.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        L_UMUR.setText("umur");

        tx_umur.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        l_agama.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_agama.setText("Agama");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("status");

        combo_status.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_status.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Menikah", "Belum Menikah" }));

        combo_agama.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        combo_agama.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Islam", "Kristen Protestan", "Kristen Katolik", "Hindu", "Budha", "Konghucu", " " }));

        l_peker.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_peker.setText("Pekerjaan");

        l_id.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        l_id.setText("ID Pasien");

        tx_id.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabel8.setText("exampe id p0001");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(l_lname)
                    .addComponent(l_fname)
                    .addComponent(l_gender)
                    .addComponent(l_tl)
                    .addComponent(l_alamat)
                    .addComponent(l_tm)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(l_agama)
                    .addComponent(l_id))
                .addGap(49, 49, 49)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(tx_ayah, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(tx_dokter, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(tx_lname, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                                        .addComponent(tx_fname))
                                    .addComponent(combo_agama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(combo_gender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(combo_dayl, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(combo_monthl, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(combo_yearl, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(combo_daym, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(20, 20, 20)
                                        .addComponent(combo_monthm, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(combo_yearm, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(tx_id, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel8)))
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(68, 68, 68)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabel5)
                                                    .addComponent(jLabel4)
                                                    .addComponent(l_diagnosa)
                                                    .addComponent(l_peker)
                                                    .addComponent(L_UMUR)
                                                    .addComponent(l_darah)
                                                    .addComponent(jLabel9)
                                                    .addComponent(l_kruangan)
                                                    .addComponent(jLabel1))
                                                .addGap(5, 5, 5))
                                            .addComponent(l_nmruangan, javax.swing.GroupLayout.Alignment.TRAILING))
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(17, 17, 17)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(tx_umur, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(tx_peker, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(combo_darah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(combo_status, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(18, 18, 18)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(combo_kruangan, 0, 153, Short.MAX_VALUE)
                                                    .addComponent(combo_nmruangan, 0, 153, Short.MAX_VALUE)
                                                    .addComponent(combo_loca, 0, 153, Short.MAX_VALUE)))))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(180, 180, 180)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(tx_dp, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(tx_diagnosa, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 298, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(b_save)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(b_clear))))
                        .addGap(39, 39, 39)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addComponent(jLabel2)))
                .addGap(16, 16, 16)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(l_id)
                            .addComponent(tx_id, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(l_peker)
                        .addComponent(tx_peker, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(L_UMUR)
                                    .addComponent(tx_umur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(combo_darah, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(l_darah)
                                    .addComponent(l_fname)
                                    .addComponent(tx_fname, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(combo_status, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel9)
                                    .addComponent(l_lname)
                                    .addComponent(tx_lname, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(combo_nmruangan, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(l_nmruangan)
                                    .addComponent(l_gender)
                                    .addComponent(combo_gender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(19, 19, 19)
                                .addComponent(l_tm)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(l_kruangan)
                            .addComponent(combo_kruangan, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(combo_daym, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(combo_monthm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(combo_yearm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(combo_monthl)
                                    .addComponent(combo_yearl)))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(l_tl)
                                .addComponent(combo_dayl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(16, 16, 16)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(tx_ayah, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(l_agama)
                        .addGap(17, 17, 17))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(combo_loca, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tx_dokter, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(combo_agama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tx_diagnosa, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(l_diagnosa))
                        .addGap(2, 2, 2)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addComponent(tx_dp, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(l_alamat)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(jLabel1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(b_save, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(b_clear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        jMenuBar1.setPreferredSize(new java.awt.Dimension(56, 30));

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/back.png"))); // NOI18N
        jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenu1MousePressed(evt);
            }
        });
        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void jMenu1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu1MousePressed
        // TODO add your handling code here:
        new UserForm().setVisible(true);
        dispose();
        
    }//GEN-LAST:event_jMenu1MousePressed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        new UserForm().setVisible(true);
        dispose();
    }//GEN-LAST:event_formWindowClosing

    private void b_clearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_clearActionPerformed
        // TODO add your handling code here:
        tx_id.setText("");
        tx_fname.setText("");
        tx_lname.setText("");
        tx_ayah.setText("");
        txarea_alamat.setText("");
        tx_peker.setText("");
        tx_umur.setText("");
        tx_dokter.setText("");
        tx_diagnosa.setText("");
        tx_dp.setText("");
    }//GEN-LAST:event_b_clearActionPerformed

    private void b_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_saveActionPerformed
        // TODO add your handling code here:
        savePasien();
    }//GEN-LAST:event_b_saveActionPerformed

    private void combo_nmruanganActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_nmruanganActionPerformed
        // TODO add your handling code here:
         lokasiRuangan();
    }//GEN-LAST:event_combo_nmruanganActionPerformed

    private void combo_kruanganActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_kruanganActionPerformed
        // TODO add your handling code here:
        lokasiRuangan();
    }//GEN-LAST:event_combo_kruanganActionPerformed

    private void combo_yearmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_yearmActionPerformed
        // TODO add your handling code here:
        umur();
    }//GEN-LAST:event_combo_yearmActionPerformed

    private void combo_yearlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_yearlActionPerformed
        // TODO add your handling code here:
        umur();
    }//GEN-LAST:event_combo_yearlActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PendaftaranForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PendaftaranForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PendaftaranForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PendaftaranForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PendaftaranForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel L_UMUR;
    private javax.swing.JButton b_clear;
    private javax.swing.JButton b_save;
    private javax.swing.JComboBox combo_agama;
    private javax.swing.JComboBox combo_darah;
    private javax.swing.JComboBox combo_dayl;
    private javax.swing.JComboBox combo_daym;
    private javax.swing.JComboBox combo_gender;
    private javax.swing.JComboBox combo_kruangan;
    private javax.swing.JComboBox combo_loca;
    private javax.swing.JComboBox combo_monthl;
    private javax.swing.JComboBox combo_monthm;
    private javax.swing.JComboBox combo_nmruangan;
    private javax.swing.JComboBox combo_status;
    private javax.swing.JComboBox combo_yearl;
    private javax.swing.JComboBox combo_yearm;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel l_agama;
    private javax.swing.JLabel l_alamat;
    private javax.swing.JLabel l_darah;
    private javax.swing.JLabel l_diagnosa;
    private javax.swing.JLabel l_fname;
    private javax.swing.JLabel l_gender;
    private javax.swing.JLabel l_id;
    private javax.swing.JLabel l_kruangan;
    private javax.swing.JLabel l_lname;
    private javax.swing.JLabel l_nmruangan;
    private javax.swing.JLabel l_peker;
    private javax.swing.JLabel l_tl;
    private javax.swing.JLabel l_tm;
    private javax.swing.JTextField tx_ayah;
    private javax.swing.JTextField tx_diagnosa;
    private javax.swing.JTextField tx_dokter;
    private javax.swing.JTextField tx_dp;
    private javax.swing.JTextField tx_fname;
    private javax.swing.JTextField tx_id;
    private javax.swing.JTextField tx_lname;
    private javax.swing.JTextField tx_peker;
    private javax.swing.JTextField tx_searchid;
    private javax.swing.JTextField tx_umur;
    private javax.swing.JTextArea txarea_alamat;
    // End of variables declaration//GEN-END:variables
}
